<template>
	<view>
		<view class="wrap">
			<view @click="ertong()">获取儿童信息</view>
			<view @click="verCode()">获取验证码</view>
			<view @click="glassesUlr()">点击注册</view>
			<input type="text" placeholder="请输入验证码" v-model="passowrd">
			<view @click="glassesLogin()">点击登录</view>
			<view @click="tong()">获取用户信息</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				email:'453631211@qq.com',
				phone:'18765395630',
				mode:'手机phone',
				mode1:'邮箱email',
				passowrd:'',
				id:''
			}
		},
		onLoad() {
			
		},
		methods:{
			ertong(){
				var that = this;
				uni.request({
					url:"https://akeso.com.cn/api/wear/children",
					method:'GET',
					data:{
						id:that.id
					},
					header: {
						'Content-type':'multipart/form-data',
					},
					success(res) {
						console.log("儿童信息res",res);
					}
				})
			},
			//获取登录儿童
			tong(){
				var that = this;
				var token = this.$common.getStorages('glaLogin');
				uni.request({
					url:"https://akeso.com.cn/api/v4/users/get_children",
					method:'GET',
					header: {
						Authorization:"bearer "+token
					},
					success(res) {
						that.id = res.data.user.id
						console.log("登录",res.data.user.id);
					}
				})
			},
			verCode(){
				var data = {
					source:this.mode1,
					email:this.email,
					type:'注册regist',
					lang:"zh-cn"
				};
				this.$http.glassesEst({
					url:"send_code",
					method:'GET',
					
				})
			},
			//登录
			glassesLogin(){
				var data = {
					source:'email',
					email:this.email,
					password:123456,
					lang:"zh-cn"
				};
				this.$http.glassesEst({
					url:'',
					method:'POST',
					data:data,
				}).then(res=>{
					console.log(res,"登录");
					this.$common.setStorage("glaLogin",res.data.data.authentication_token);
				})
			},
			//注册
			glassesUlr(){
				var data={
					source:'email',
					email:this.email,
					password:this.password
				};
				this.$http.glassesEst({
					url:"regist",
					method:'Post',
					data:data
				}).then(res =>{
					console.log(res);
				})
				console.log(this.$http.glassesEst,"this.$http.glassesUlr");
			}
		}
		
	}
</script>

<style>
	.wrap view{
		width: 300rpx;
		height: 300rpx;
		margin: 20rpx auto;
		background-color: aqua;
		line-height: 300rpx;
		text-align: center;
	}
</style>